#include "StdAfx.h"
#include "ISoundEffect_observer.h"
#include "ISoundEffect.h"
#include "IAudio.h"

namespace audio {

ISoundEffect_observer::ISoundEffect_observer(ISoundEffect* _pISoundEffect, int _sleepTime) {
	
	m_pISoundEffect = _pISoundEffect;
	mifSleepTime = _sleepTime;
	m_bRunning = true;
	
	m_pThread = new thread::Thread(this);
	m_pThread->start();
}

ISoundEffect_observer::~ISoundEffect_observer(void)
{
	m_pThread->stop();
	DELETE_POINTER(m_pThread);
}

void ISoundEffect_observer::stop() {
	m_bRunning = false;
}

void ISoundEffect_observer::run() {
	
	/*
	while (m_bRunning) {		
		
		// Destroy ISoundEffect after finished playing
		if (m_pISoundEffect->getState() != ISOUNDEFFECT_PLAYING) {			
			coreGetAudio()->destroyISoundEffect(m_pISoundEffect);
			m_bRunning = false;				
		}		
		m_pThread->sleep(mifSleepTime);
	}
	*/
	delete this;
}

}